<?php
namespace app\admin\controller;

use app\common\model\CompanyTag as CompanyTagModel;
/**
 * 寺院标签控制器
 * Class CompanyTag
 * @package app\index\controller
 */
class CompanyTag extends Base
{
    /**
     * [getIndex  寺院标注列表]
     * @param
     * @return mixed|\think\response\Json
     * @author [C。]
     */
    public function getIndex()
    {
        $model = new CompanyTagModel;
        $param = input('param.');
        $user = $this->user;
        try{
            $tag = $model->findData($param['comid'],'comid');
        }catch(\Exception $e){
            return admin_json(-1, '获取失败'.$e->getMessage());
        }
        writelog('获取寺院标注', 1,$user);
        return admin_json(1, '获取成功',$tag);
    }
    /**
     * [getIndex  寺院标注添加]
     * @param
     * @return mixed|\think\response\Json
     * @author [C。]
     */
    public function postAdd()
    {
        $model = new CompanyTagModel;
        $param = input('param.');
        $user = $this->user;
        try{
            if(empty($param['comid'])){
                return admin_json(-1, 'comid为空');
            }
            $id = $model->addData($param);
        }catch(\Exception $e){
            return admin_json(-1, '添加失败'.$e->getMessage());
        }
        writelog('添加寺院标注'.$id, 1,$user);
        return admin_json(1, '添加成功');
    }
    /**
     * [postEdit  寺院标注修改]
     * @param
     * @return mixed|\think\response\Json
     * @author [C。]
     */
    public function postEdit()
    {
        $model = new CompanyTagModel;
        $param = input('param.');
        $user = $this->user;
        try{
            $model->editData($param);
        }catch(\Exception $e){
            return admin_json(-1, '修改失败'.$e->getMessage());
        }
        writelog('修改寺院标注'.$param['id'], 1,$user);
        return admin_json(1, '修改成功');
    }
}